package com.foreknow.web;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.foreknow.entity.User;
import com.foreknow.service.ConstanttypeService;
import com.foreknow.utils.Constance;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/constanttype")
public class ConstanttypeController {

@Autowired
    ConstanttypeService constanttypeService;
    //获取所有医生职称字段的方法
    @RequestMapping(value = "queryConstantName",method = RequestMethod.GET)
    public String queryDeptName(@RequestParam Map<String,Object> para) throws JsonProcessingException {
        HashMap<String,Object> hs =new HashMap();

        List list = constanttypeService.queryAll();
        hs.put("list",list);
        if (list.size()>0){
            hs.put("meta",new Constance("获取用户所在科室成功",200));
        }else {
            hs.put("meta",new Constance("获取用户所在科室失败",401));
        }
        ObjectMapper objectMapper =new ObjectMapper();
        return objectMapper.writeValueAsString(hs);
    }
}
